<html>
<head>
<title>Pork Spam detector</title>
<script src="js/jquery.js" type="text/javascript"></script>
<!--script src="http://code.jquery.com/jquery-latest.js"></script-->

<script type="text/javascript"> 

function submit_check() {
	$.post("/check", { body: $("#body_text").val()	},
			function(data) {
				if (data != "error") {
					$("#class_res").html("<h3>"+data+"</h3>");
				}
			}, "json")
	return false;

}

function submit_train() {
	$.post("/train", { tag: $("#category").val(),
			   body: $("#body_text").val() }, 
		function(data) {
			if (data != "error") {
				$("#class_res").html("<h3>"+data+"</h3>");
			}
		}, "json")
	return false;

}

function start() {
		$("#submit_check").bind("click", submit_check);
		$("#submit_train").bind("click", submit_train);
	}
		
	$().ready(start);
		
</script>

<style type="text/css">
	body {
		background-color: #FFFFFF;
		color: #666666;
		font-family: arial, sans;
		font-size: 14px;
		line-height: 1.7em;
		margin: 1em 2em;
	}

	h2 {
		font-size: 1.45em;
		letter-spacing: -0.02em;
    	}

	.small {
		font-size: 12px;
	}

	input {
		color: #781351;
		background: #fee3ad;
		border: 1px solid #781351
	}

	.submit input {
		color: #000;
		background: #ffa20f;
		border: 2px outset #d7b9c9
	} 

	label {
		width: 4em;
		float: left;
		text-align: left;
		display: block
	}

	fieldset {
		border: 1px solid #781351;
		width: 20em
	}

	textarea {
		width: 400px;
		height: 150px;
	}

    
</style>

<head>

<body>
	<img src="/images/pork_banner.jpg">
	<p class="small"> This is pork, a Bayesian classifier. It`s Reverend adapted to run over app engine's datastore. Enjoy the ham, throw out the spam ! The original Reverend can be found <a href="http://divmod.org/trac/wiki/DivmodReverend"> here </a></p>

<div id="class_res" class="small">[classification result]</div>

<form id="classification">
 <fieldset>

    	<br><br>
    	<label for="body_text">Body</label><textarea id="body_text" name="body_text" rownum=120 colnum=120></textarea><br>

    	<br><br>
    	<input type="submit" id="submit_check" name="submit_check" value="Classify"> 
    	<input type="reset" value="Clean"> 

    	<br><br>
    	<br>
	<select id="category" name="category">
        	<option value="positive">positive</option>
        	<option value="negative">negative</option>
    	</select>
    	<input type="submit" id="submit_train" name="submit_train" value="Train"> 
    	
 </fieldset>
</form>
</body>
</html>

